import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Solution solution = new Solution();
        int n = scanner.nextInt();
        int[] array = new int[100];
        int[][] array2 = new int[100][100];
        for(int i=0;i<n;i++){
            array[i]=scanner.nextInt();
        }
        for(int i=0;i<n;i++){
            for (int j=0;j<2;j++) {
                array2[i][j]=scanner.nextInt();
            }
        }
        System.out.println(solution.isZeroArray(array,array2));
    }
}

class Solution1 {
    public boolean isZeroArray(int[] nums, int[][] queries) {
        int n = queries.length;
        for (int i = 0; i < n; i++) {
            for (int j = queries[i][0]; j <= queries[i][1]; j++) {
                if(nums[j]!=0){
                    nums[j]--;
                }
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (nums[i]!=0) {
                return false;
            }
        }
        return true;
    }
}

class Solution {
    public boolean isZeroArray(int[] nums, int[][] queries) {
        int n = nums.length;
        int[] array = new int[n + 1];
        for (int[] x : queries) {
            array[x[0]]++;
            array[x[1] + 1]--;
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += array[i];
            if (nums[i] > sum) {
                return false;
            }
        }
        return true;
    }
}